using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class HACHTOANInfo
    {
		#region Local Variable
		public enum Field
		{
			NO,
			LINE,
			SOBT,
			LOAICT,
			NGAYGD,
			TKNO,
			TKCO,
			SOTIEN,
			NOIDUNG
		}
		private Int64 _NO;
		private Int32 _LINE;
		private String _SOBT;
		private String _LOAICT;
		private DateTime _NGAYGD;
		private String _TKNO;
		private String _TKCO;
		private Double _SOTIEN;
		private String _NOIDUNG;
		
		public Int64 NO{	get{ return _NO;} set{_NO = value;} }
		public Int32 LINE{	get{ return _LINE;} set{_LINE = value;} }
		public String SOBT{	get{ return _SOBT;} set{_SOBT = value;} }
		public String LOAICT{	get{ return _LOAICT;} set{_LOAICT = value;} }
		public DateTime NGAYGD{	get{ return _NGAYGD;} set{_NGAYGD = value;} }
		public String TKNO{	get{ return _TKNO;} set{_TKNO = value;} }
		public String TKCO{	get{ return _TKCO;} set{_TKCO = value;} }
		public Double SOTIEN{	get{ return _SOTIEN;} set{_SOTIEN = value;} }
		public String NOIDUNG{	get{ return _NOIDUNG;} set{_NOIDUNG = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public HACHTOANInfo()
		{
			_NO = 0;
			_LINE = 0;
			_SOBT = "";
			_LOAICT = "";
			_NGAYGD = DateTime.Now;
			_TKNO = "";
			_TKCO = "";
			_SOTIEN = 0;
			_NOIDUNG = "";
		}
		public HACHTOANInfo(
		Int64 NO,
		Int32 LINE,
		String SOBT,
		String LOAICT,
		DateTime NGAYGD,
		String TKNO,
		String TKCO,
		Double SOTIEN,
		String NOIDUNG
		)
		{
			_NO = NO;
			_LINE = LINE;
			_SOBT = SOBT;
			_LOAICT = LOAICT;
			_NGAYGD = NGAYGD;
			_TKNO = TKNO;
			_TKCO = TKCO;
			_SOTIEN = SOTIEN;
			_NOIDUNG = NOIDUNG;
		}
		public HACHTOANInfo(DataRow dr)
		{
			if (dr != null)
			{
				_NO = dr[Field.NO.ToString()] == DBNull.Value?0:Convert.ToInt64(dr[Field.NO.ToString()]);
				_LINE = dr[Field.LINE.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.LINE.ToString()]);
				_SOBT = dr[Field.SOBT.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.SOBT.ToString()]);
				_LOAICT = dr[Field.LOAICT.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.LOAICT.ToString()]);
				_NGAYGD = dr[Field.NGAYGD.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.NGAYGD.ToString()]);
				_TKNO = dr[Field.TKNO.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.TKNO.ToString()]);
				_TKCO = dr[Field.TKCO.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.TKCO.ToString()]);
				_SOTIEN = dr[Field.SOTIEN.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOTIEN.ToString()]);
				_NOIDUNG = dr[Field.NOIDUNG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.NOIDUNG.ToString()]);
			}
		}
		public HACHTOANInfo(DataRowView dr)
		{
			if (dr != null)
			{
				_NO = dr[Field.NO.ToString()] == DBNull.Value?0:Convert.ToInt64(dr[Field.NO.ToString()]);
				_LINE = dr[Field.LINE.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.LINE.ToString()]);
				_SOBT = dr[Field.SOBT.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.SOBT.ToString()]);
				_LOAICT = dr[Field.LOAICT.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.LOAICT.ToString()]);
				_NGAYGD = dr[Field.NGAYGD.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.NGAYGD.ToString()]);
				_TKNO = dr[Field.TKNO.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.TKNO.ToString()]);
				_TKCO = dr[Field.TKCO.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.TKCO.ToString()]);
				_SOTIEN = dr[Field.SOTIEN.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOTIEN.ToString()]);
				_NOIDUNG = dr[Field.NOIDUNG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.NOIDUNG.ToString()]);
			}
		}
		public HACHTOANInfo(HACHTOANInfo objEntr)
		{			
			_NO = objEntr.NO;			
			_LINE = objEntr.LINE;			
			_SOBT = objEntr.SOBT;			
			_LOAICT = objEntr.LOAICT;			
			_NGAYGD = objEntr.NGAYGD;			
			_TKNO = objEntr.TKNO;			
			_TKCO = objEntr.TKCO;			
			_SOTIEN = objEntr.SOTIEN;			
			_NOIDUNG = objEntr.NOIDUNG;			
		}
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("HACHTOAN");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.NO.ToString(), typeof(Int64)),
				new DataColumn(Field.LINE.ToString(), typeof(Int32)),
				new DataColumn(Field.SOBT.ToString(), typeof(String)),
				new DataColumn(Field.LOAICT.ToString(), typeof(String)),
				new DataColumn(Field.NGAYGD.ToString(), typeof(DateTime)),
				new DataColumn(Field.TKNO.ToString(), typeof(String)),
				new DataColumn(Field.TKCO.ToString(), typeof(String)),
				new DataColumn(Field.SOTIEN.ToString(), typeof(Double)),
				new DataColumn(Field.NOIDUNG.ToString(), typeof(String))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.NO.ToString()] = _NO;
			row[Field.LINE.ToString()] = _LINE;
			row[Field.SOBT.ToString()] = _SOBT;
			row[Field.LOAICT.ToString()] = _LOAICT;
			row[Field.NGAYGD.ToString()] = _NGAYGD;
			row[Field.TKNO.ToString()] = _TKNO;
			row[Field.TKCO.ToString()] = _TKCO;
			row[Field.SOTIEN.ToString()] = _SOTIEN;
			row[Field.NOIDUNG.ToString()] = _NOIDUNG;
			return row;
		}
        #endregion InitTable
    }
}
